package com.cheng.service.transit.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.cheng.dao.transit.InOutStorageinfoDao;
import com.cheng.dao.transit.TransitinfoDao;
import com.cheng.domain.transit.InOutStorageInfo;
import com.cheng.domain.transit.TransitInfo;
import com.cheng.service.transit.InOutStorageinfoService;
@Service
@Transactional
public class InOutStorageinfoServiceIMpl implements InOutStorageinfoService {
	@Autowired
	private InOutStorageinfoDao inOutStorageinfoDao;
	@Autowired
	private TransitinfoDao transitInfoDao;

	@Override
	public void save(InOutStorageInfo model, Integer transitinfoid) {
		//保存出入库信息
		inOutStorageinfoDao.save(model);
		//查找需要关联的运输信息单
		TransitInfo transitinfo = transitInfoDao.findOne(transitinfoid);
		transitinfo.getInOutStorageInfos().add(model);
		//如果快递到达网点，修改快递状态，获取网点地址，方便设置派送地址地图显示
		if ("到达网点".equals(model.getOperation())) {
			transitinfo.setStatus("到达网点");
			transitinfo.setOutletAddress(model.getAddress());
		}
	}

}
